{---------------------------------------------------------------------
#
#	Apple Macintosh Developer Technical Support
#
#	MultiFinder-Aware Simple TextEdit Sample Application
#
#	OOPTESample
#
#	UDocument.p		-	Pascal Source
#
#	Copyright © 1988, 1989 Apple Computer, Inc.
#	All rights reserved.
#
#	Version:		
#					1.00					04/89
#
#	Components:     
#					BuildOOPTESample		April 1, 1989
#					MOOPTESample.p			April 1, 1989
#					OOPTESample.make		April 1, 1989
#					TECommon.h				April 1, 1989
#					TESampleGlue.a			April 1, 1989
#					TESample.r				April 1, 1989
#					UApplication.p			April 1, 1989
#					UApplication.inc1.p		April 1, 1989
#					UDocument.p				April 1, 1989
#					UDocument.inc1.p		April 1, 1989
#					UTEDocument.p			April 1, 1989
#					UTEDocument.inc1.p		April 1, 1989
#					UTESample.p				April 1, 1989
#					UTESample.inc1.p		April 1, 1989
#
---------------------------------------------------------------------}

UNIT UDocument;

INTERFACE

USES
	Types, QuickDraw, Events, Desk, ToolUtils, OSUtils, Controls,
	TextEdit, Traps, Windows, Dialogs, 
	ObjIntf;

TYPE
	TDocument = OBJECT(TObject)
		fDocWindow: WindowPtr;
		
		PROCEDURE TDocument.IDocument(resID: integer);
		PROCEDURE TDocument.Free; OVERRIDE;
		
		{ You will need to override these in your subclasses, since they }
		{ do nothing by default. }
		PROCEDURE TDocument.DoZoom(partCode: integer);
		PROCEDURE TDocument.DoGrow(theEvent: EventRecord);
		PROCEDURE TDocument.DoContent(theEvent: EventRecord);
		PROCEDURE TDocument.DoKeyDown(theEvent: EventRecord);
		PROCEDURE TDocument.DoActivate(becomingActive: Boolean);
		PROCEDURE TDocument.DoUpdate;
		
		{ File Handling Routines }
		PROCEDURE TDocument.DoOpen;
		PROCEDURE TDocument.DoClose;	{ By default, we just delete ourself. }
		PROCEDURE TDocument.DoSave;
		PROCEDURE TDocument.DoSaveAs;
		PROCEDURE TDocument.DoRevert;
		PROCEDURE TDocument.DoPrint;
		
		{ Standard Edit Menu actions }
		PROCEDURE TDocument.DoUndo;
		PROCEDURE TDocument.DoCut;
		PROCEDURE TDocument.DoCopy;
		PROCEDURE TDocument.DoPaste;
		PROCEDURE TDocument.DoClear;
		PROCEDURE TDocument.DoSelectAll;
		
		{ Idle Time routines: you can use these to do cursor handling, }
		{ TE caret blinking, marquee effects, etc. }
		PROCEDURE TDocument.DoIdle;
		FUNCTION TDocument.CalcIdle:Longint;
		PROCEDURE TDocument.AdjustCursor(where: Point); { where is in local coords. }

		{ Query state of document - useful for adjusting menu state }
		FUNCTION TDocument.HaveUndo: Boolean;
		FUNCTION TDocument.HaveSelection: Boolean;
		FUNCTION TDocument.HavePaste: Boolean;
		FUNCTION TDocument.CanClose: Boolean;
		FUNCTION TDocument.CanSave: Boolean;
		FUNCTION TDocument.CanSaveAs: Boolean;
		FUNCTION TDocument.CanRevert: Boolean;
		FUNCTION TDocument.CanPrint: Boolean;
		
		{ Utility routine to get window pointer for document }
		FUNCTION TDocument.GetDocWindow: WindowPtr;
	END;
		
		
	TDocumentLink = OBJECT(TObject)
		fNext: TDocumentLink;
		fDoc: TDocument;
		
		PROCEDURE TDocumentLink.IDocumentLink(n:TDocumentLink; v:TDocument);
		FUNCTION TDocumentLink.GetNext:TDocumentLink;
		FUNCTION TDocumentLink.GetDoc: TDocument;
		PROCEDURE TDocumentLink.SetNext(aLink:TDocumentLink);
		PROCEDURE TDocumentLink.SetDoc(aDoc:TDocument);
	END;

	TDocumentList = OBJECT(TObject)
		fDocList: TDocumentLink;	{ the first link in our list }
		fNumDocs: integer;			{ the number of elements in the list }
		
		PROCEDURE TDocumentList.IDocumentList;
		PROCEDURE TDocumentList.AddDoc(doc:TDocument);
		PROCEDURE TDocumentList.RemoveDoc(doc:TDocument);
		FUNCTION TDocumentList.FindDoc(window:WindowPtr): TDocument;
		FUNCTION TDocumentList.NumDocs:integer;
	END;
		
IMPLEMENTATION

{$I UDocument.inc1.p}

END.